<?php

/*
Admin Main (admin.php)
*/

$page_title = "Admin Main Page";
$rank_check = 7;
include "../header.inc.php";

$smallPrice = 49.99;
$basicPrice = 79.99;
$superPrice = 99.99;
$ultraPrice = 149.99;

if ($getGame[package] == 1) { $negativePrice = $smallPrice; $package = "Small"; }
if ($getGame[package] == 2) { $negativePrice = $basicPrice; $package = "Basic"; }
if ($getGame[package] == 3) { $negativePrice = $superPrice; $package = "Super"; }
if ($getGame[package] == 4) { $negativePrice = $ultraPrice; $package = "Ultra"; }
if ($getGame[package] == 5) { $negativePrice = 0; $package = "Free"; }

$smallPrice = 49.99 - $negativePrice;
$basicPrice = 79.99 - $negativePrice;
$superPrice = 99.99 - $negativePrice;
$ultraPrice = 149.99 - $negativePrice;

if ($cheapPrice < 0) { $cheapPrice = 0; }
if ($smallPrice < 0) { $smallPrice = 0; }
if ($basicPrice < 0) { $basicPrice = 0; }
if ($superPrice < 0) { $superPrice = 0; }
if ($ultraPrice < 0) { $ultraPrice = 0; }

if ($upgradeto == 1) { $upgradeto2 = "Small"; $price = $smallPrice; }
if ($upgradeto == 2) { $upgradeto2 = "Basic"; $price = $basicPrice; }
if ($upgradeto == 3) { $upgradeto2 = "Super"; $price = $superPrice; }
if ($upgradeto == 4) { $upgradeto2 = "Ultra"; $price = $ultraPrice; }
if ($upgradeto == 5) { $upgradeto2 = "Cheapskates"; $price = $cheapPrice; }

$credit = $getGame[credit] / 100;

print "$openHTML";

if ($act != "pay")
{

ECHO <<<END

<p>You have chosen to upgrade from a $package Package to a $upgradeto2 Package! The cost will be \$$price (USD)! You have \$$credit OPG Credit to spend on upgrading, please enter the ammount of credit (in dollars) that you want to use to upgrade.</p>

<form action=admin_upgrade_game2.php?game=$game&upgradeto=$upgradeto&act=pay method=post>
<p>Use $'s in Credit: <input type=text name=use_credit size=8><br>
<input type=submit name=payment_type value="Order Package using Paypal!"> 
<input type=submit name=payment_type value="Order Package using Check/Money Order!">
</p></form>

<p><font size=-1>By ordering any package you agree to <a href=../rules.php>all of our terms and conditions.</a></font></p>

END;

}

if ($act == "pay")
{
	if ($use_credit > $credit) { die("You do not have that much credit!$closeHTML"); }
	$price = $price - $use_credit;
	if ($price < 0) { $price = 0; }
	
	if ($payment_type == "Order Package using Check/Money Order!")
	{
		print "
		<p>
		Package: $upgradeto2<br>
		Using Credit: \$$use_credit<br>
		Total Due: $price
		</p>
		
		<p>Make checks/money orders payable to Stephen Knight then mail them WITH THIS FORM 		to:</p>
		
		<p>Stephen knight<br>
		2544 Martin S.E.<Br>
		Grand Rapids, MI. 49507</p>
		";
	}
	
	if ($payment_type == "Order Package using Paypal!")
	{
		print "
		<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">
		<input type=\"hidden\" name=\"cmd\" value=\"_xclick\">
		<input type=\"hidden\" name=\"business\" value=\"steve@brkn.net\">
		<input type=\"hidden\" name=\"item_name\" value=\"OPG - Game: $game - $upgradeto2 - 		\$$use_credit Credit\">
		<input type=\"hidden\" name=\"amount\" value=\"$price\">
		<input type=\"hidden\" name=\"no_note\" value=\"1\">
		<input type=\"hidden\" name=\"currency_code\" value=\"USD\">
		<input type=\"image\" src=\"https://www.paypal.com/images/x-click-but01.gif\" 		border=\"0\" name=\"submit\" alt=\"Make payments with PayPal - it's fast, free and secure!\">
		</form>
		";
	}
	
	print "<p><font size=-1>By ordering any package you agree to <a href=../rules.php>all of our terms and conditions.</a></font></p>";

}

print "$closeHTML";
?>
